package com.example.myapplication;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class MainAdapter extends RecyclerView.Adapter<MainAdapter.MainHolder> {
    private Context mContext;
    private List<Long> mList;

    public MainAdapter(Context mContext, List<Long> mList) {
        this.mContext = mContext;
        this.mList = mList;
    }

    @NonNull

    @Override
    public MainHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new MainHolder(LayoutInflater.from(mContext).inflate(R.layout.item_main_item, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull MainAdapter.MainHolder holder, int position) {
        Log.d("MainAdapter", "当前时间 = " + mList.get(position));
        holder.tvTime.setTime(mList.get(position));
    }

    @Override
    public int getItemCount() {
        return mList == null ? 0 : mList.size();
    }

    class MainHolder extends RecyclerView.ViewHolder {
        TimeTextView tvTime;

        public MainHolder(@NonNull View itemView) {
            super(itemView);
            tvTime = itemView.findViewById(R.id.tvFightTiming);
        }
    }
}
